//
//  ViewController.m
//  04-QQMusic
//
//  Created by 韩旭 on 16/7/19.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (nonatomic, strong) UIImageView *imageBack;
@property (nonatomic, strong) UILabel *lable;
@property (nonatomic, strong) UIImageView *playImage;
@property (nonatomic, strong) UIImageView *playBlackImage;
@property (nonatomic, strong) UIButton *btnDown;
@property (nonatomic, strong) UISlider *slider;
@property (nonatomic, strong) UIPageControl *pageControl;
@property (nonatomic, strong) UIImageView *imagePlay;
@property (nonatomic, strong) UIImageView *imageLeft;
@property (nonatomic, strong) UIImageView *imageRight;
//下边的图片
@property (nonatomic, strong) UIImageView *imageMulti;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatBackImage];
    [self creatBtnDown];
    [self creatBlackImage];
    [self creatPlayImage];
    [self creatSlider];
    [self creatMuiltImage];
}
- (void)creatBackImage {
    self.imageBack = [UIImageView packImageViewFrame:self.view.bounds imagePhoto:[UIImage imageNamed:@"player_albumblur_default"] colorBack:[UIColor clearColor] action:nil target:self];
    [self.view addSubview:_imageBack];
}

- (void)creatBlackImage {
    self.playBlackImage = [UIImageView packImageViewFrame:CGRectMake(0, 0, WIDETH * 0.79, WIDETH * 0.79) imagePhoto:[UIImage imageNamed:@"playButton"] colorBack:[UIColor clearColor] action:nil target:self];
    self.playBlackImage.center = CGPointMake(WIDETH / 2, HEIGHT * 0.415);
    [self.view addSubview:_playBlackImage];
}

- (void)creatPlayImage {
    self.playImage = [UIImageView packImageViewFrame:CGRectMake(0, 0, WIDETH * 0.715, WIDETH * 0.715) imagePhoto:[UIImage imageNamed:@"player_albumcover_default"] colorBack:[UIColor clearColor] action:nil target:self];
    _playImage.center = CGPointMake(WIDETH / 2, HEIGHT * 0.415);
    [self.view addSubview:_playImage];
}

- (void)creatBtnDown {
    self.btnDown = [UIButton packWithBtnText:nil colorBack:nil frame:CGRectMake(0, 0, 50, 50) titleColor:nil action:nil target:self imageBack:[UIImage imageNamed:@"xiangxia "]];
    _btnDown.center = CGPointMake(32, 45);
    [self.view addSubview:_btnDown];
    UILabel *lableName = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
    lableName.backgroundColor = [UIColor clearColor];
    lableName.text = @"歌名";
    lableName.textColor = [UIColor colorWithRed:0.65 green:0.65 blue:0.65 alpha:1.00];
    lableName.textAlignment = 1;
    lableName.font = [UIFont systemFontOfSize:25];
    lableName.center = CGPointMake(WIDETH / 2, _btnDown.center.y);
    [self.view addSubview:lableName];
    
    UILabel *lableLineLeft = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDETH * 0.05, 2)];
    lableLineLeft.backgroundColor = [UIColor colorWithRed:0.32 green:0.32 blue:0.32 alpha:1.00];
    lableLineLeft.center = CGPointMake(WIDETH / 2.7, HEIGHT * 0.1);
    UILabel *lableSongName = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDETH * 0.15, HEIGHT * 0.02)];
    lableSongName.text = @"李荣浩";
    lableSongName.textAlignment = 1;
    lableSongName.textColor = [UIColor colorWithRed:0.75 green:0.75 blue:0.75 alpha:1.00];
    lableSongName.backgroundColor = [UIColor clearColor];
    lableSongName.center = CGPointMake(WIDETH / 2, lableLineLeft.center.y);
    UILabel *lableRight = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, lableLineLeft.frame.size.width, lableLineLeft.frame.size.height)];
    lableRight.backgroundColor = [UIColor colorWithRed:0.32 green:0.32 blue:0.32 alpha:1.00];
    lableRight.center = CGPointMake(lableLineLeft.center.x + (lableName.center.x - lableLineLeft.center.x) * 2, lableLineLeft.center.y);
    
    UIButton *btnSet = [UIButton packWithBtnText:nil colorBack:nil frame:CGRectMake(0, 0, _btnDown.frame.size.width, _btnDown.frame.size.height) titleColor:nil action:nil target:self imageBack:[UIImage imageNamed:@"sandian"]];
    btnSet.center = CGPointMake(_btnDown.center.x + (lableName.center.x - _btnDown.center.x) * 2, _btnDown.center.y);
    UIImageView *imageHQ = [UIImageView packImageViewFrame:CGRectMake(0, 0, WIDETH * 0.2, HEIGHT * 0.03) imagePhoto:[UIImage imageNamed:@"downloadHQ"] colorBack:[UIColor clearColor] action:nil target:self];
    imageHQ.center = CGPointMake((lableName.center.x - lableLineLeft.center.x) / 2 + lableLineLeft.center.x, HEIGHT * 0.15);
    UIImageView *imageAlone = [UIImageView packImageViewFrame:CGRectMake(0, 0, WIDETH * 0.11, HEIGHT * 0.025) imagePhoto:[UIImage imageNamed:@"exclusive"] colorBack:[UIColor clearColor] action:nil target:self];
    imageAlone.center = CGPointMake((lableRight.center.x - lableName.center.x) / 2 + lableName.center.x , imageHQ.center.y);
    [self.view addSubview:imageAlone];
    [self.view addSubview:imageHQ];
    [self.view addSubview:btnSet];
    [self.view addSubview:lableRight];
    [self.view addSubview:lableSongName];
    [self.view addSubview:lableLineLeft];
}

- (void)creatSlider {
    self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 0, 110, 20)];
    self.pageControl.numberOfPages = 3;
    self.pageControl.center = CGPointMake(WIDETH / 2, HEIGHT * 0.74);
    self.pageControl.pageIndicatorTintColor = [UIColor colorWithRed:0.31 green:0.31 blue:0.31 alpha:1.00];
    [self.view addSubview:_pageControl];
    
    self.slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, WIDETH * 0.8, 20)];
    _slider.value = 0;
    _slider.minimumValue = 0;
    _slider.maximumValue = 1;
    _slider.center = CGPointMake(WIDETH / 2, HEIGHT * 0.78);
    _slider.backgroundColor = [UIColor clearColor];
    [_slider setThumbImage:[UIImage imageNamed:@"player_slider_playback_thumb"] forState:UIControlStateNormal];
    [_slider setMinimumTrackImage:[UIImage imageNamed:@"player_slider_playback_left"] forState:UIControlStateNormal];
    [_slider setMaximumTrackImage:[UIImage imageNamed:@"player_slider_playback_right"] forState:UIControlStateNormal];
    [self.view addSubview:_slider];
    [_slider addTarget:self action:@selector(sliderWithBtn:) forControlEvents:UIControlEventValueChanged];
    self.imagePlay = [UIImageView packImageViewFrame:CGRectMake(0, 0, WIDETH * 0.18, WIDETH * 0.18) imagePhoto:[UIImage imageNamed:@"player_btn_play_normal"] colorBack:[UIColor clearColor] action:@selector(addPlayImage:) target:self];
    _imagePlay.center = CGPointMake(WIDETH / 2, HEIGHT * 0.85);
    self.imageLeft = [UIImageView packImageViewFrame:CGRectMake(0, 0, WIDETH * 0.18, WIDETH * 0.18) imagePhoto:[UIImage imageNamed:@"player_btn_pre_highlight"] colorBack:[UIColor clearColor] action:nil target:self];
    _imageLeft.center = CGPointMake(WIDETH / 3.5, _imagePlay.center.y);
    self.imageRight = [UIImageView packImageViewFrame:CGRectMake(0, 0, WIDETH * 0.18, WIDETH * 0.18) imagePhoto:[UIImage imageNamed:@"player_btn_next_normal"] colorBack:[UIColor clearColor] action:nil target:self];
    self.imageRight.center = CGPointMake((_imagePlay.center.x - _imageLeft.center.x) + _imagePlay.center.x, _imagePlay.center.y);
    [self.view addSubview:_imageRight];
    [self.view addSubview:_imageLeft];
    [self.view addSubview:_imagePlay];
}
- (void)creatMuiltImage {
    NSArray *arrImage = [NSArray arrayWithObjects:@"5", @"1", @"2", @"4", @"3", nil];
    for (NSInteger i = 0; i < arrImage.count ; i++) {
        self.imageMulti = [UIImageView packImageViewFrame:CGRectMake(WIDETH * 0.9 / 5 * i + WIDETH * 0.1 , HEIGHT * 0.93, WIDETH * 0.38 / 5, HEIGHT * 0.039) imagePhoto:[UIImage imageNamed:arrImage[i]] colorBack:[UIColor clearColor] action:nil target:self];
        self.imageMulti.tag = 1001 + i;
        [self.view addSubview:_imageMulti];
    }
}
- (void)addImageSecond:(UITapGestureRecognizer *)tap {
    self.imageMulti.image = [UIImage imageNamed:@"2"];
    [tap removeTarget:self action:@selector(addImageSecond:)];
    [tap addTarget:self action:@selector(changImageSecond:)];
}
- (void)changImageSecond:(UITapGestureRecognizer *)tap {
    self.imageMulti.image = [UIImage imageNamed:@"3"];
    [tap removeTarget:self action:@selector(changImageSecond:)];
    [tap addTarget:self action:@selector(addChangeImage:)];
}
- (void)addChangeImage:(UITapGestureRecognizer *)tap {
    self.imageMulti.image = [UIImage imageNamed:@"1"];
    [tap removeTarget:self action:@selector(addChangeImage:)];
    [tap addTarget:self action:@selector(addImageSecond:)];
}
- (void)addPlayImage:(UITapGestureRecognizer *)tap {
    self.imagePlay.image = [UIImage imageNamed:@"player_btn_pause_highlight"];
    [tap removeTarget:self action:@selector(addPlayImage:)];
    [tap addTarget:self action:@selector(changeTap:)];
}
- (void)changeTap:(UITapGestureRecognizer *)tap {
    self.imagePlay.image = [UIImage imageNamed:@"player_btn_play_normal"];
    [tap removeTarget:self action:@selector(changeTap:)];
    [tap addTarget:self action:@selector(addPlayImage:)];
}
- (void)sliderWithBtn:(UISlider *)slider {
  NSLog(@"%ld", (NSInteger)slider.value);
}
@end
